{% extends 'cms/base/dashboard_base.html' %}
{% load post_filters %}

{% block head %}

{% endblock %}

{% block title %}
    User IP Management
{% endblock %}

{% block main %}
    <section class="content">
        <div class="container-fluid pt-4">
            <div class="row">
                <div class="col-sm-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="row p-2 d-flex">
                                <p class="h3">User IP</p>
                                <div class="ml-auto">
                                    {{ day_time | datetime_timezone_format}} <b class="text-danger">Total: {{ ip_count_num }}</b>
                                </div>
                            </div>
                            <div class="row">
                                <table class="table table-bordered table-hover">
                                    <thead class="thead-light">
                                    <tr>
                                        <th style="width: 10%;">#</th>
                                        <th>Ip_Address</th>
                                        <th>Ip_Location</th>
                                        <th>End_Point</th>
                                        <th style="width: 10%;">Create_time</th>
                                        <th style="width: 15%;">actions</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for item in list_data %}
                                        <tr>
                                            <td>{{ forloop.counter|calculate_index:current_page }}</td>
                                            <td>{{ item.ip_address }}</td>
                                            <td>{{ item.ip_location }}</td>
                                            <td>{{ item.end_point }}</td>
                                            <td>{{ item.create_time | time_format }}</td>
                                            <td>
                                                <a href="#"
                                                   class="btn btn-info btn-xs">TBA</a>
                                                <button class="btn btn-danger btn-xs delete-btn"
                                                        data-post-id="{{ item.id }}">
                                                    TBA
                                                </button>
                                            </td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>

                            <div class="row">
                                <div class="col-sm-5">
                                    <p class="pull-left">第{{ current_page }}页/总共{{ num_pages }}页</p>
                                </div>
                                <div class="col-sm-7">
                                    <div class="dataTables_paginate paging_simple_numbers float-right">
                                        <ul class="pagination">
                                            {#上一页#}
                                            {% if page_obj.has_previous %}
                                                <li class="paginate_button page-item "><a class="page-link" href="?p=
                                                        {{ page_obj.previous_page_number }}{{ url_query }}">上一页</a></li>
                                            {% else %}
                                                <li class="paginate_button page-item previous disabled"><a
                                                        class="page-link"
                                                        href="javascript:void(0);">上一页</a>
                                                </li>
                                            {% endif %}

                                            {# 是否需要出现三个点 #}
                                            {% if left_has_more %}
                                                <li class="paginate_button page-item "><a class="page-link" href="?p=1">1</a>
                                                </li>
                                                <li class="paginate_button page-item "><a class="page-link"
                                                                                          href="javascript:void(0);">...</a>
                                                </li>
                                            {% endif %}

                                            {# 左边的页码 #}
                                            {% for left_page in left_pages %}
                                                <li class="paginate_button page-item "><a class="page-link" href="?p=
                                                        {{ left_page }}{{ url_query }}">{{ left_page }}</a></li>
                                            {% endfor %}

                                            {# 当前的页面 #}
                                            <li class="paginate_button page-item  active"><a class="page-link" href="?p=
                                                    {{ current_page }}{{ url_query }}">{{ current_page }}</a></li>

                                            {# 右边的页码 #}
                                            {% for right_page in right_pages %}
                                                <li class="paginate_button page-item "><a class="page-link" href="?p=
                                                        {{ right_page }}{{ url_query }}">{{ right_page }}</a></li>
                                            {% endfor %}

                                            {# 用来控制右边三个点 #}
                                            {% if right_has_more %}
                                                <li class="paginate_button page-item "><a class="page-link"
                                                                                          href="javascript:void(0);">...</a>
                                                </li>
                                                <li class="paginate_button page-item "><a class="page-link" href="?p=
                                                        {{ num_pages }}{{ url_query }}">{{ num_pages }}</a></li>
                                            {% endif %}

                                            {#下一页#}
                                            {% if page_obj.has_next %}
                                                <li class="paginate_button page-item next"><a class="page-link" href="?p=
                                                        {{ page_obj.next_page_number }}{{ url_query }}">下一页</a></li>
                                            {% else %}
                                                <li class="paginate_button page-item next disabled"><a class="page-link"
                                                                                                       href="javascript:void(0);">下一页</a>
                                                </li>
                                            {% endif %}
                                        </ul>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>



{% endblock %}
